import type { UserInfo } from '@vben/types';

import { requestClient } from '#/api/request';

/**
 * 获取用户信息
 */
export async function getUserInfoApi(): Promise<UserInfo> {
  const response = await requestClient.get<any>('/user/detail');
  
  // 将后端字段映射为前端期望的字段
  return {
    userId: response.id?.toString() || '',
    username: response.userName || '',
    realName: response.realName || '',
    avatar: response.userIcon || '', // 将 userIcon 映射为 avatar
    roles: [], // 角色信息可能需要从其他接口获取
    desc: response.email || '',
    homePath: '/dashboard',
    token: '', // token 由认证流程处理
  };
}
